<template>
   <div>
       <h1>获取作者所有信息</h1>


            <h1>全部作者</h1>
            <table border="1">
                <tr>
                    <td>id</td>
                    <td>作者名</td>
                    <td>操作</td>
                </tr>
                <tr v-for="i in auhotr_list">
                    <td>{{i.id}}</td>
                    <td>{{i.name}}</td>
                    <td><van-button @click="indexs(i.id,i.name)">查看详情</van-button></td>
                </tr>
            </table>



   </div>
</template>

<script>
export default {
   data () {
      return {
        auhotr_list:[],
      };
   },

   methods: {
       //跳转详情信息
       indexs:function(aid,aname){
           var a = localStorage.getItem(aname)
           if (a){
               a++
               localStorage.setItem(aname,a)
           }else{
               localStorage.setItem(aname,1)
           }
           this.$router.push({path:'/get_books',query:{aid:aid}})
       },
       //获取所有作者
       get_author:function(){
           this.axios.get(this.localhost+'author/')
           .then(res=>{
               console.log(res.data);
               this.auhotr_list = res.data;
           })
       },

   },

   computed: {},

   mounted() {
       this.get_author();
   },

   components: {}
}
</script>
<style lang='css' scoped>

</style>    